package com.yuejian.neusoft.yuejian_24.model;


import com.yuejian.neusoft.yuejian_24.javaBean.Class;
import com.yuejian.neusoft.yuejian_24.listener.ListListener;
import com.yuejian.neusoft.yuejian_24.service.ClassService;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by q4549 on 2017/11/2.
 */

public class ClassModel {
    private Retrofit retrofit;
    public ClassModel(){
        retrofit =new Retrofit.Builder()
                .baseUrl("http://10.0.2.2/yuejian/")
                .addConverterFactory(GsonConverterFactory.create())
                .build();
    }
    public void classlist(String master_id, final ListListener listener){
        ClassService classService = retrofit.create(ClassService.class);
        Call call = classService.classlist(master_id);
        Callback<List<Class>> callback = new Callback<List<Class>>() {
            @Override
            public void onResponse(Call<List<Class>> call, Response<List<Class>> response) {
                listener.onResponse(response.body());
            }

            @Override
            public void onFailure(Call<List<Class>> call, Throwable t) {

            }
        };
        call.enqueue(callback);
    }

}
